setProvince();
setOneClass(1);

function setProvince()
{
	Ts_areaInfo.getAreaClassByUpId('000000000000000',function(data){
		DWRUtil.removeAllOptions('province');
		DWRUtil.addOptions('province',{'':'请选择'});
		DWRUtil.addOptions('province',data);
	})
}
function setCitys(prov)
{
   var provence=prov;
	 Ts_areaInfo.getAreaClassByUpId(provence,function(data){
		DWRUtil.removeAllOptions('eparchy_code');
		DWRUtil.addOptions('eparchy_code',{'':'请选择'});
		DWRUtil.addOptions('eparchy_code',data);
		//DWRUtil.removeAllOptions('city_code');
		//DWRUtil.addOptions('city_code',{'':'请选择'});
	});
}

function setAreas(city_id){
	Ts_areaInfo.getAreaClassByUpId(city_id,function(data){
	 	DWRUtil.removeAllOptions('city_code');
     	DWRUtil.addOptions('city_code',{'':'请选择'});
	 	DWRUtil.addOptions('city_code',data);
	});
}





function setOneClass(val){
	Ts_categoryInfo.getCatClassByUpId("000000000000000",val,setSort1);
}
function setSort1(map_data)
{
	var factory = $("sort1");
	DWRUtil.removeAllOptions("sort1");
	DWRUtil.addOptions('sort1',{'':'请选择'});
	DWRUtil.addOptions("sort1",map_data);
}


  
  var type = "1";
// 设置二级分类
function setSecondClass(val) {
	var up_class_id = val; 
 
	Ts_categoryInfo.getCatClassByUpId(up_class_id, type, setSort2);
}
function setSort2(map_data) {
	DWRUtil.removeAllOptions("sort2");
	DWRUtil.addOptions("sort2", {'':'请选择'});
	DWRUtil.addOptions("sort2", map_data);
	//$("sort3").style.display = "none";
	var item = $("sort2").length;

}
// 设置三级分类
function setTherdClass(val) {
	var up_class_id = val;
	Ts_categoryInfo.getCatClassByUpId(up_class_id, type, setSort3);
}
function setSort3(map_data) {
	if (map_data != null) {
		DWRUtil.removeAllOptions("sort3");
		DWRUtil.addOptions("sort3", {'':'请选择'});
		DWRUtil.addOptions("sort3", map_data);
	}
}
 
function setTypeName1(obj){
	  var idx = obj.value;
		$("class_id3").value="";
		$("class_id2").value="";
		$("class_id1").value=idx;
		//$("class_name").value=DWRUtil.getText(obj.name);
		//$("count").value=obj.name;
}


function setTypeName2(obj){
	  var idx = obj.value;
	  $("class_id3").value="";
		$("class_id2").value=idx;
		//$("class_name").value=DWRUtil.getText(obj.name);
		//$("count").value=obj.name;
}

function setTypeName3(obj){
	  var idx = obj.value;
		$("class_id3").value=idx;
		//$("class_name").value=DWRUtil.getText(obj.name);
		//$("count").value=obj.name;
}




function submitForm(){
//分类拼串

	   var wen_name = document.addForm.wen_name.value;
	  if(wen_name == "")
	  {
		alert("请填写网站名称!");
		document.getElementById("wen_name").focus();
	  	return false;
	  }

	   var save_dir = document.addForm.save_dir.value;
	  if(save_dir == "")
	  {
		alert("请填写保存地址!");
		document.getElementById("save_dir").focus();
	  	return false;
	  }

	  
		var class_attr_str = "";
		if(document.getElementById("sort1").value!=""){
			class_attr_str = document.getElementById("sort1").value ;
			if(document.getElementById("sort2").value!=""){
				class_attr_str = document.getElementById("sort2").value ;
				if(document.getElementById("sort3").value!=""){
					class_attr_str = document.getElementById("sort3").value ;
				}
			}
		
		}
	  if(class_attr_str==""){
			document.getElementById("class_attr").value = document.getElementById("class_attr_bak").value;
		}else{
			document.getElementById("class_attr").value = class_attr_str;
		}	
		if(document.getElementById("class_attr").value == ""){
				alert("请选择所属分类！");
				document.getElementById("sort1").focus();
				return false;
		}
	  //地区拼串
		var area_attr_str = "";
		if(document.getElementById("province").value!=""){
			area_attr_str = document.getElementById("province").value;
			if(document.getElementById("eparchy_code").value!=""){
				area_attr_str = document.getElementById("eparchy_code").value;
				if(document.getElementById("city_code").value!=""){
					area_attr_str = document.getElementById("city_code").value;
				}
			}
		}
		if(area_attr_str==""){
			document.getElementById("area_attr").value = document.getElementById("area_attr_bak").value;
		}else{
			document.getElementById("area_attr").value = area_attr_str;
		}	
	  var province = document.addForm.area_attr.value;
	  if(null == province || province == "")
	  {
	  	alert("请选择所在地区!");
			document.getElementById("province").focus();
	  	return false;
	  }
}

function ChangeOrg(){
	document.getElementById("org1").style.display = "none";
	document.getElementById("org2").style.display = "inline";
	document.getElementById("area_attr").value = "";
}

function ChangeClassStyle(){
	document.getElementById("class_attr").value = "";
	document.getElementById("flag_code").value = "1";
	document.getElementById("classId1").style.display="none";
	document.getElementById("classId2").style.display="";
}


